package com.apes.fn.business.insurance.modle;

import com.alibaba.fastjson.annotation.JSONField;
import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.Model;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import com.apes.framework.plugin.fileserver.File;
import com.apes.framework.plugin.soe.annotations.State;
import com.apes.framework.plugin.soe.annotations.States;
import com.apes.framework.util.ApesConst;
import com.apes.framework.util.DateUtil;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;
import java.util.Date;

/**
 * @program: apes-server
 * @description 到账信息
 * @author: czs
 * @create: 2022-06-16 17:52
 **/
@Entity
@EntityListeners(DefaultPersistListener.class)
@Getter
@Setter
@Table(name = InAccountInformation.CONST_TABLE_NAME)
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
public class InAccountInformation extends Model {
    public final static String CONST_TABLE_NAME = "commission_account_information";

    @Id
    @Column(name = "id", nullable = false, length = 20)
    @ApesGenerator(code = CONST_TABLE_NAME, name = "佣金到账信息")
    @Comment("到账信息编码")
    private String id;

    @States(name = "单据状态", values = {
            @State(id = "portion", name = "部分到账"),
            @State(id = "all", name = "全部到账"),
    })
    @Column(name = "state", length = 32, nullable = false)
    @Comment("单据状态")
    private String state = "create";

    @JSONField(format = DateUtil.SHOW_DATE_FORMAT)
    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "in_account_date")
    @Comment("到账时间")
    private Date inAccountDate;

    @Comment("实际到账金额")
    @Column(name = "real_in_account_amount", columnDefinition = ApesConst.FIELD_MONEY_16_4_0)
    private double realInAccountAmount = 0;

    @Comment("实际到账比率")
    @Column(name = "real_in_account_rate", columnDefinition = ApesConst.FIELD_MONEY_16_4_0)
    private double realInAccountRate = 0;

    @Column(name = "remark")
    @Comment("备注")
    private String remark;

    @Column(name = "operator_people")
    @Comment("操作人")
    private String operatorPeople;

    @ManyToOne(optional = false)
    @JoinColumn(name = "commission_Reconciliation",referencedColumnName = "id",nullable = false)
    private CommissionReconciliation commissionReconciliation;


    @File
    @Lob
    @Basic(fetch = FetchType.LAZY)
    @Column(name = "PHOTO",columnDefinition = "CLOB")
    @Comment("图片")
    private String photo;
}
